package com.amigo.online.provider.manager.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.provider.manager.model.entity.UserPhotosTbl;
import com.amigo.online.provider.manager.service.UserPhotosService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

/**
 * 用户相册
 *
 * @author Administrator
 */
@RestController
@RequestMapping(value = "/userphotos", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class UserPhotosController extends BaseController {

    @Resource
    private UserPhotosService userPhotosService;

    @PostMapping(value = "/getUserPhotosList")
    public ResponseEntity<Response> getUserPhotosList(@RequestBody UserPhotosTbl userPhotosTbl) {

        JSONObject result = new JSONObject();
        // 分页语句
        Page<Object> page = PageHelper.startPage(userPhotosTbl.getPageNo(), 12);
        List<UserPhotosTbl> userPhotosList = userPhotosService.findUserPhotosTblList(userPhotosTbl);
        result.put("userPhotosList", userPhotosList);
        result.put("pagetotal", page.getTotal());
        return success(result);
    }


    @PutMapping(value = "/updateUserPhotos")
    public ResponseEntity<Response> updateUserPhotos(@RequestBody UserPhotosTbl userPhotosTbl) {
        return success(userPhotosService.updateUserPhotos(userPhotosTbl));
    }


}
